package org.t236.user;


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication(scanBasePackages = {"org.t236.user", "org.t236.feign"})
@EnableFeignClients(basePackages = "org.t236.feign")
@EnableDiscoveryClient
public class UserApp {

    @Bean
    @LoadBalanced
    RestTemplate restTemplate() {
        return new RestTemplate();
    }


    public static void main(String[] args) {
        SpringApplication.run(UserApp.class, args);
    }

//    @GetMapping("/{userId}")
//    public AjaxResult find(@PathVariable("userId") Long userId) {
//
//        User user = users.stream().filter(u -> u.getId().equals(userId)).collect(Collectors.toList()).get(0);
//        AjaxResult ajaxResult =  restTemplate.getForObject("http://localhost:8001/findByUserId?userId=1", AjaxResult.class);
//        user.setOrders((List<Order>) ajaxResult.getData());
//        return AjaxResult.success(user);
//    }

}
